<!DOCTYPE html>
<html lang="en" xmlns:layout="http://www.w3.org/1999/xhtml"
      layout:decorate="~{admin/adminJs}" xmlns:v-on="http://www.w3.org/1999/xhtml">

<body layout:fragment="content">
    <!--搜索栏-->
    <div id="toolbar">
        <div id="search" style="padding:15px">

        </div>
        <div id="operator" style="padding:0 0 15px 15px">
            <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'" v-on:click="add()">添加</a>
            <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-remove'" v-on:click="deleted()">删除</a>
        </div>
    </div>
    <!--列表-->
    <table id="table" style="width:100%;" >

    </table>

    <script>

        var filter={  };
        var roleId=RequestUtils.get('roleId');
        filter.roleId=roleId;

        function reload(){
            $('#table').datagrid('reload',filter);
        }

        function closeDialog(isRefresh) {
            if(isRefresh){
                reload();
            }
            $('#editDialog').dialog("close");
        }

        var vm=  new Vue({
            el: '#toolbar',
            data:filter,
            methods: {
                query:function () {
                    reload();
                },
                add:function () {
                    EasyuiUtils.openWindows("chooseUsers",'新增',700,600,'/admin/user/user/chooseUsers');
                },
                deleted:function () {
                    var row=EasyuiUtils.getSelected("#table");
                    if(row){
                        EasyuiUtils.confirmSubmit('确定删除?',"/admin/user/user/deleteUserRole",{userRoleId:row.userRoleId});
                    }

                }
            }
        });

        function chooseUsersCallBack(userIds) { //选择userid回调
            EasyuiUtils.confirmSave("/admin/user/user/usersRoleSave",{
                userIds:userIds,
                roleId:roleId
            },function () {
                $('#chooseUsers').dialog("close");
                reload();
            });
        }

        $('#table').datagrid({
            url:'/admin/user/user/listByRoleId',
            queryParams:filter,
            columns:[
                [
                    {field:'id',title:'id',align:'center',width:'10%',hidden:false,checkbox:true},
                    {field:'userName',title:'用户名',align:'center',width:'15%',hidden:false},
                    {field:'realName',title:'昵称',align:'center',width:'15%',hidden:false},
                    /*{field:'password',title:'密码',align:'center',width:'10%',hidden:false},*/
                    {field:'deptId',title:'学校',align:'center',width:'15%',hidden:true},
                    {field:'profession',title:'专业',align:'center',width:'15%',hidden:false},
                    {field:'secondaryCollege',title:'二级学院',align:'center',width:'15%',hidden:false},
                    {field:'mobilePhone',title:'手机号码',align:'center',width:'15%',hidden:false},
                    {field:'createTime',title:'创建时间',align:'center',width:'20%',hidden:false},
                    {field:'userRoleId',title:'user_roel_id',align:'center',width:'10%',hidden:true}
                ]
            ],
            striped:true,
            pagination:true,
            rownumbers:true,
            singleSelect:true,
            toolbar:'#toolbar'
        });


    </script>
</body>

</html>